- Todennäköisyys ja Bayesilainen tilastotiede
- Bayesin kaava
- Uskottavuusfunktio
- Priorijakauma
- Posteriorijakauma
- Bayesilaiset menetelmät käytännössä
- Kalvot löytyvät osoitteesta github.com/hpesonen
4/26/2019
\[p(\theta \mid y) = \frac{p(y \mid \theta)p(\theta)}{p(y)}\]
\[p(\theta \mid y) = \frac{p(y \mid \theta)p(\theta)}{p(y)}\]
\[p(y \mid \theta) = \theta^y(1-\theta)^{1-y}\]
\[p(y_1, \ldots, y_N \mid \theta) = \prod_{i=1}^N p(y_i \mid \theta) = \theta^{\sum_{i} y_i} (1- \theta)^{N-\sum_{i}y_i} \]
\[ \begin{aligned} p(\theta \mid y = (n,N-n)) & \propto p(y=(n,N-n) \mid \theta) p(\theta) \\ & = \theta^{n}(1-\theta)^{N-n}\theta^4(1-\theta)^4 \\ & = \theta^{n+4}(1-\theta)^{N-n+4} \end{aligned} \]
\[\sum_{i=1}^m p(M_i) = 1\]
\[\sum_{i=1}p(M_i \mid y) = 1\]
\[p(y) = \int p(y \mid \theta) p(\theta) \mathsf{d} \theta\]
Usein prioritieto liittyy nimenomaisesti tietämykseen mallin tuottamista realistisista arvoista
\[ \begin{aligned} p(y^\prime \mid y) & = \int p(y^\prime \mid \theta, y) p(\theta \mid y) \mathsf{d} \theta \\ & = \int p(y^\prime \mid \theta) p(\theta \mid y) \mathsf{d} \theta \end{aligned} \]
## ## Model comparison: ## (ordered by highest ELPD) ## ## elpd_diff se_diff ## post4 0.0 0.0 ## post3 -3.5 2.5 ## post2 -6.0 3.9 ## post1 -42.2 8.7
## ## Model comparison: ## (negative 'elpd_diff' favors 1st model, positive favors 2nd) ## ## elpd_diff se ## 42.2 8.7
## ## Model comparison: ## (negative 'elpd_diff' favors 1st model, positive favors 2nd) ## ## elpd_diff se ## 3.5 2.5
## ## Model comparison: ## (negative 'elpd_diff' favors 1st model, positive favors 2nd) ## ## elpd_diff se ## 6.0 3.9
## ## Call: ## glm(formula = lot1 ~ log(u), family = Gamma, data = clotting) ## ## Deviance Residuals: ## Min 1Q Median 3Q Max ## -0.04008 -0.03756 -0.02637 0.02905 0.08641 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) -0.0165544 0.0009275 -17.85 4.28e-07 *** ## log(u) 0.0153431 0.0004150 36.98 2.75e-09 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## (Dispersion parameter for Gamma family taken to be 0.002446059) ## ## Null deviance: 3.51283 on 8 degrees of freedom ## Residual deviance: 0.01673 on 7 degrees of freedom ## AIC: 37.99 ## ## Number of Fisher Scoring iterations: 3
## ## Call: ## glm(formula = lot2 ~ log(u), family = Gamma, data = clotting) ## ## Deviance Residuals: ## Min 1Q Median 3Q Max ## -0.05574 -0.02925 0.01030 0.01714 0.06371 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) -0.0239085 0.0013265 -18.02 4.00e-07 *** ## log(u) 0.0235992 0.0005768 40.91 1.36e-09 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## (Dispersion parameter for Gamma family taken to be 0.001813354) ## ## Null deviance: 3.118557 on 8 degrees of freedom ## Residual deviance: 0.012672 on 7 degrees of freedom ## AIC: 27.032 ## ## Number of Fisher Scoring iterations: 3
## stan_glm ## family: Gamma [inverse] ## formula: clot_time ~ log_plasma * lot_id ## observations: 18 ## predictors: 4 ## ------ ## Median MAD_SD ## (Intercept) -0.016 0.007 ## log_plasma 0.015 0.003 ## lot_id2 -0.007 0.013 ## log_plasma:lot_id2 0.008 0.006 ## ## Auxiliary parameter(s): ## Median MAD_SD ## shape 7.942 2.577 ## ## Sample avg. posterior predictive distribution of y: ## Median MAD_SD ## mean_PPD 31.944 4.859 ## ## ------ ## * For help interpreting the printed output see ?print.stanreg ## * For info on the priors used see ?prior_summary.stanreg
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## (Intercept) dist100 arsenic ## 0.000 -0.894 0.461
## Loading required package: gridExtra
## ## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr': ## ## combine
## Warning: Removed 39 rows containing missing values (geom_point).